﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using JM.JCY.BusinessEntity;
using JM.JCY.Proxy;
using NCS.IConnect.ApplicationContexts;
using JM.JCY.Common;
using JM.JCY.Common.Utilities;
using Microsoft.SharePoint;


namespace JM.JCY.SharePointComponent.IncorruptArchives.CreateJianChaGanbuPeiOuCongYe
{
    public partial class CreateJianChaGanbuPeiOuCongYeUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
        }

        protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
        {
            using (IncorruptProxy proxy = new IncorruptProxy())
            {
                var newDT = new IncorruptDataSet.T_JianChaGanbuPeiOuCongYeDataTable();
                var newRow = newDT.NewT_JianChaGanbuPeiOuCongYeRow();

                newRow.FillerCompany = this.txtFillerCompany.Text;
                newRow.FillDate = this.dtFillDate.SelectedDate;
                newRow.Filler = this.txtFiller.Text;
                newRow.Gender = this.rbGender.SelectedValue;
                newRow.Age = this.txtAge.Text;
                newRow.Company_Dept = this.txtCompany.Text;
                newRow.Position = this.txtPosition.Text;
                newRow.Rank = this.txtRank.Text;


                // relation1
                newRow.RelatedName1 = this.txtRelatedName1.Text;
                newRow.Relationship1 = this.txtRelationship1.Text;
                newRow.RelatedGender1 = this.rbRelatedGender1.SelectedValue;
                newRow.RelatedAge1 = this.txtRelatedAge1.Text;
                newRow.RelatedCompany1 = this.txtRelatedCompany1.Text;
                newRow.RelatedPosition1 = this.txtRelatedPosition1.Text;
                //relation2
                newRow.RelatedName2 = this.txtRelatedName2.Text;
                newRow.Relationship2 = this.txtRelationship2.Text;
                newRow.RelatedGender2 = this.rbRelatedGender2.SelectedValue;
                newRow.RelatedAge2 = this.txtRelatedAge2.Text;
                newRow.RelatedCompany2 = this.txtRelatedCompany2.Text;
                newRow.RelatedPosition2 = this.txtRelatedPosition2.Text;
                //relation3
                newRow.RelatedName3 = this.txtRelatedName3.Text;
                newRow.Relationship3 = this.txtRelationship3.Text;
                newRow.RelatedGender3 = this.rbRelatedGender3.SelectedValue;
                newRow.RelatedAge3 = this.txtRelatedAge3.Text;
                newRow.RelatedCompany3 = this.txtRelatedCompany3.Text;
                newRow.RelatedPosition3 = this.txtRelatedPosition3.Text;

                newRow.ApprovalComments = this.txtApprovalComments.Text;
                JCYUtility.UpdateCommonFields(newRow, "Iori");
                newDT.AddT_JianChaGanbuPeiOuCongYeRow(newRow);
                proxy.UpdateJianChaGanbuPeiOuCongYe(newDT);

                Response.Redirect("JianChaGanbuPeiOuCongYe.aspx");
            }
        }

        protected void imgCancel_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("JianChaGanbuPeiOuCongYe.aspx");
        }
    }
}
